package org.trackcore.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.trackcore.model.entity.BaseLog;
import org.trackcore.mapper.BaseLogMapper;
import org.trackcore.service.BaseLogService;
import org.springframework.stereotype.Service;
import org.trackcore.utils.DataUtils;

import java.util.Date;
import java.util.Map;

@Service
public class BaseLogServiceImpl
        extends ServiceImpl<BaseLogMapper, BaseLog>
        implements BaseLogService {
    @Override
    public BaseLog saveBaseLog(Map<String, Object> rawData) {
        BaseLog log = new BaseLog();
        log.setId(DataUtils.getString(rawData, "id"));
        log.setAppId(DataUtils.getString(rawData, "appId", "default"));
        log.setTimestamp(DataUtils.getLong(rawData, "timestamp"));
        log.setCreatedAt(new Date());
        save(log);
        return log;
    }

}
